package com.hks360.car_treasure.dialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

import com.hks360.car_treasure.activity.LoginActivity;
import com.hks360.car_treasure.common.AppConfig;
import com.hks360.car_treasure.common.PrefKey;
import com.hks360.library.util.CommonUtil;
import com.hks360.library.util.PrefUtil;

/**
 * Created by rwq on 2016/4/15.
 */
public class TipDialog {
    private Activity activity;
    private Context context;
    private int count1 = 0;

    public String getMessage() {
        return Message;
    }

    public void setMessage(String message) {
        Message = message;
    }

    private String Message;
    public TipDialog(Activity activity, Context context) {
        this.activity = activity;
        this.context = context;
    }

    public void CreateDialog(final int count){
        count1 = count;
        final AlertDialog.Builder builder = new AlertDialog.Builder(context);
        final AlertDialog dialog = builder.create();
        builder.setTitle("提示").setMessage(Message).setNegativeButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                i = count1;
                switch (i){
                    case 1:
                        PrefUtil.removeKey(context, PrefKey.LOGIN_IS_AUTO);
                        CommonUtil.openActivity(context, LoginActivity.class);
                        AppConfig.mComManager.unLoading();
                        activity.finish();
                        break;
                    case 2:
                        dialog.dismiss();
                        break;
                }

            }
        });
        builder.setPositiveButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialog.dismiss();
            }
        });
        builder.show();
    }

}
